package com.aceitunaproject.webclient.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

public class MessageBox extends DialogBox {

	private final static Label textLabel = new Label("");
    final VerticalPanel panel = new VerticalPanel();
    
    public static void showDialog(String header,  String content) {
        final DialogBox abox = new MessageBox(header, content);
        abox.center();
      
    }

	public MessageBox (String header,  String content) {
		final MessageBox box = this;
        this.setText(header);
        panel.add(new Label(content));
        final Button buttonClose = new Button("Close",new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                box.hide();
            }
        });
        // few empty labels to make widget larger
        
        getTextlabel().setSize("auto","25px");
        panel.add(getTextlabel());
        panel.add(getTextlabel());
        buttonClose.setWidth("90px");
        panel.add(buttonClose);
        panel.setCellHorizontalAlignment(buttonClose, HasAlignment.ALIGN_RIGHT);
        this.add(panel);
		
	}

	/**
	 * @return the textlabel
	 */
	 Label getTextlabel() {
		return textLabel;
	}
	
}
